package com.dongbing.demo.modules.system.controller;

import com.baomidou.dynamic.datasource.annotation.DS;


import com.dongbing.demo.modules.system.mapper.*;
import com.dongbing.demo.modules.system.service.RePasswod;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.UnsupportedEncodingException;

/**
 * @author  Mr. Dong
 * @create  2021/9/28 9:53
 * @desc    mybatis 多数据源配置 需要引入多数据源依赖 yml文件需要添加相关配置
 **/
@RestController
public class DataSourceController {

    @Autowired
    private ImportantFireMapper importantFireMapper;
    @Autowired
    private ImportantViolationMapper importantViolation;
    @Autowired
    private  EpidemicDisasterMapper epidemicDisasterMapper;
    @Autowired
    private NaturalDisasterMapper naturalDisasterMapper;
    @Autowired
    private SafetyDisasterMapper safetyDisasterMapper;
    @Autowired
    private TEnvironmentalTroubleMapper tEnvironmentalTroubleMapper;
    @Autowired
    private ThieveryDisasterMapper thieveryDisasterMapper;
   @Resource
   private RePasswod rePasswod;
    /**
     * 重大火灾
     * @return
     */
    @DS("master_dbTwo")
    @RequestMapping("/demo-api/fire")
    public Object fire() {

        return importantFireMapper.findAllImportantFireMapper();

    }

    /**重大·违规
     *
     * @return
     */
    @DS("master_dbTwo")
    @RequestMapping("/demo-api/violation")
    public Object violation() {

        return importantViolation.selectImportantViolationVo();

    }

    /***
     * 疫情灾害
     * @return
     */
    @DS("master_dbTwo")
    @RequestMapping("/demo-api/epidemicDisaster")
    public Object epidemicDisaster() {

        return epidemicDisasterMapper.selectTEpidemicDisasterVo();

    }
    /***
     * 自然灾害
     * @return
     */
    @DS("master_dbTwo")
    @RequestMapping("/demo-api/naturalDisaster")
    public Object naturalDisaster() {

        return naturalDisasterMapper.selectNaturalDisasterVo();

    }
    /***
     * 安全灾害
     * @return
     */
    @DS("master_dbTwo")
    @RequestMapping("/demo-api/safetyDisaster")
    public Object safetyDisaster() {

        return safetyDisasterMapper.selectSafetyDisasterVo();
    }
    /***
     * 环境问题
     * @return
     */
    @DS("master_dbTwo")
    @RequestMapping("/demo-api/environmental")
    public Object environmental() {

        return tEnvironmentalTroubleMapper.selectTEnvironmentalTroubleVo();
    }
    /***
     * 盗窃事件
     * @return
     */
    @DS("master_dbTwo")
    @RequestMapping("/demo-api/thieveryname")
    public Object thieveryname() {

        return thieveryDisasterMapper.selectThieveryDisasterVo();
    }

    /***
     * 安全卫士跳转环境api 密码验证  密码验证 后端加密
     */
//    @DS("master_dbOne")
//  @RequestMapping("/ps/{name}&{pass}")
//    public Object ps(@PathVariable String name,@PathVariable String pass) throws UnsupportedEncodingException {
//
//        name = java.net.URLDecoder.decode(name, "UTF-8");
//        pass =java.net.URLDecoder.decode(pass, "UTF-8");
//        System.out.println(pass);
////        return thieveryDisasterMapper.selectThieveryDisasterVo();
//      return   rePasswod.RePasswod(name,pass);
//    }


}

//    @Autowired
//    private DongMapper dongMapper;
//
//    @Autowired
//    private StudentMapper studentMapper;
//    @Autowired
//    private IotHistorySensorDataMapper iotHistorySensorDataMapper;

//    @DS("master_dbOne")
//    @RequestMapping("/dataSource")
//    public Object dataSource() {
////    List cc= dongMapper.selectList(null);
////        System.out.println(cc);
//        //  return   iotHistorySensorDataMapper.findAllIotHistorySensorData();
//        //return dongMapper.selectList(null);
//        // return iotHistorySensorDataMapper.selectList(null);
//        IotHistorySensorDataBo ot = new IotHistorySensorDataBo();
//        ot.setScene_id(2);  //查询 环境
//        ot.setDevice_code("1201071002");
//      //  ot.setLimit(100);
// //return iotHistorySensorDataMapper.selectStatavalue(ot);
//      //  ot.setSensor_name("总磷");
//       return  iotHistorySensorDataMapper.selectStatamount(ot);
//
//
//    }
//    @DS("master_dbTwo")
//    @RequestMapping("/dataSources")
//    public Object dataSourceS(){
//
//        return studentMapper.selectList(null);
//    }
//    @DS("master_dbOne")
//    @Scheduled(cron="0/5 * *  * * ? ")
//    public void time(){
//      //System.out.println(iotHistorySensorDataMapper.selectList(null));
//        System.out.println("你好");
//    }


